<template>
	<view>
		<view class="Registered-payment">
			<view class="Registered-payment-title">
				<view class="Tit">
					支付金额<text style="color:#ed953e ;">￥{{optionprice}}</text>
				</view>
				<view class="time">
					请在<text style="color: red;padding: 0 10px;"> {{time}}s</text>内完成支付
				</view>
			</view>
			<view class="payment-main">
				<text>缴费信息</text>
				<view class="paymain">
					<view class="left">
						费用类型
					</view>
					<view class="right">
						挂号诊断费
					</view>
				</view>

				<view class="paymain">
					<view class="left">
						就诊院区
					</view>
					<view class="right">
						二沙逼医院
					</view>
				</view>

				<view class="paymain">
					<view class="left">
						就诊科室
					</view>
					<view class="right">
						{{optiondoctorInfo}}
					</view>
				</view>

				<view class="paymain">
					<view class="left">
						医生名
					</view>
					<view class="right">
						{{optionname}}
					</view>
				</view>

				<view class="paymain">
					<view class="left">
						就诊时间
					</view>
					<view class="right">
						2023年7月31
					</view>
				</view>

				<view class="paymain">
					<view class="left">
						就诊时段
					</view>
					<view class="right">
						{{optionvalue}}
					</view>
				</view>

				<view class="paymain">
					<view class="left">
						就诊人
					</view>
					<view class="right">
						陈欢霞
					</view>
				</view>

				<view class="paymain">
					<view class="left">
						就诊卡号
					</view>
					<view class="right">
						{{data}}
					</view>
				</view>
			</view>

			<view class="">
				<view class="weixin">
					<view class="weixin-list">
						<!-- <image src="../../static/b79321987fb6e0e01c0683c03193684.png" mode=""></image> -->
						<view class="text" @click="moneypassword">微信支付</view>

					</view>


				</view>
				<view class="weixin">
					
					<view class="weixin-list">
						<!-- <image src="../../static/c8e6d00e1f88f3c979d72d89653d6e1.png" mode=""></image> -->
						<view class="text">支付宝支付</view>
							
					</view>
				</view>

			</view>
		</view>
		<!-- <button class="bottom">立即支付</button> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				time: 120,
				optiondoctorInfo: "",
				optionname: "",
				optionprice: "",
				optionvalue: "",
				data: "",
				patientName: "",
				age: "",
				phone: "",
				sex: ""



			}
		},
		methods: {
			open() {
				// 通过组件定义的ref调用uni-popup方法 ,如果传入参数 ，type 属性将失效 ，仅支持 ['top','left','bottom','right','center']
				this.$refs.popup.open('top')
			},
			fun() {
				var times1 = setInterval(() => {
					this.time--
					// console.log(this.time);
					if (this.time == 0) {
						clearInterval(times1)
					}
				}, 1000)
			},
			moneypassword() {
				this.patientName = localStorage.getItem('patientName')
				this.age = localStorage.getItem('age')
				this.phone = localStorage.getItem('phone')
				this.sex = localStorage.getItem('sex')
				// console.log(this.patientName);
				// uni.request({
				// 	url:'http://192.168.36.31:3000/patient/registration?patientName='+this.patientName+'&affiliatedDoctorId=1&sex='+this.sex+'&age='+this.age+'&phone='+this.phone+'appointmentTime=2023-01-31 14:33:00&registrationDepartment='+this.optiondoctorInfo+'&price='+this.optionprice+'&date='+this.optionvalue+'&time=2023-07-20'
				// }).then(res=>{

				// }
				uni.request({
					hearder: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					url: 'http://192.168.36.31:3000/patient/registration',
					method: 'POST',
					data: {
						patientName:this.patientName,
						affiliatedDoctorId:'1',
						sex:this.sex,
						age:this.age,
						phone:this.phone,
						appointmentTime:'2023-01-31 14:33:00',
						registrationDepartment:this.optiondoctorInfo,
						price:this.optionprice,
						date:this.optionvalue,
						time:'2023-07-20'

					},
					dataType: "json",
					success: (res) => {
						console.log(res);
					}
				})
				
				
				
				// console.log(this.$u.config.version);
				uni.navigateTo({
					url: "../../pages/Registration/Registration?optionname=" + this.optionname +
						"&optiondoctorInfo=" + this.optiondoctorInfo + "&optionprice=" + this.optionprice +
						"&optionvalue=" + this.optionvalue
				})
			},

		},
		onLoad(option) {
			this.fun()
			console.log(option);
			this.optionname = option.name
			this.optiondoctorInfo = option.doctorInfo
			this.optionprice = option.price
			this.optionvalue = option.value
			this.data = new Date().getTime();
			// console.log(this.data.getTime());

		}
	}
</script>

<style lang="scss">
	.Registered-payment {
		// background-color: #f6f7f9;

		.Registered-payment-title {
			background-color: #f6f7f9;
			padding: 16px;

			.Tit {
				font-size: 35px;
			}

			.time {
				font-size: 20px;
			}

			image {
				width: 50px;
				height: 50px;
			}

			.title {
				height: 50px;
				line-height: 50px;
				text-align: center;
			}
		}

		.payment-main {
			background-color: #fff;
			padding: 16px;

			.paymain {
				padding: 5px 0;
				color: #838383;
			}
		}

		.weixin {
			background-color: #6accb5;
			display: flex;
			color: #fff;
			margin-top: 20px;
			justify-content: center;
			border-bottom: 1px solid #eee;
			border-top: 1px solid #eee;

			.weixin-list {
				display: flex;
			}

			image {
				width: 50px;
				height: 40px;
			}

			.text {
				height: 40px;
				line-height: 40px;
			}

		}

	}

	.paymain {
		display: flex;

		.right {
			color: black;
		}

		.left {
			width: 100px;
		}
	}




	.bottom {
		background-color: lightgreen;
		width: 100%;
		height: 50px;
		position: absolute;
		color: white;
		bottom: 0;
		text-align: center;
		line-height: 50px;
	}
</style>